home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15212 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: Belgium.EU.net!news
  2. From: Christ.Vandromme@ping.be (Christ Vandromme)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Nee help with a string and temp string
  5. Date: Wed, 17 Apr 1996 21:03:30 GMT
  6. Organization: EUnet Belgium, Leuven, Belgium
  7. Message-ID: <4l3j65$gr5@news.Belgium.EU.net>
  8. References: <316C72CC.763A@cloudnet.com>
  9. NNTP-Posting-Host: dialup19.kortrijk.eunet.be
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. "Randall J. Pfeifer" <rpfeifer@cloudnet.com> wrote:
  13.  
  14. > I am writing a program that reads data, validates it, and then writes it to a new file.
  15.  
  16. > My problem involves evaluating the second line. The program works like this.
  17.  
  18. [snip]
  19.  
  20. > void examineBcard()
  21. > { int result;
  22. >   
  23.  
  24. Here lies your problem....
  25. >   strncpy(Bcard, "B", 1);
  26.  
  27. strncpy only copies 1 character, it does NOT ADD a '\0'.
  28.  
  29. So Add the folowing line:
  30.  
  31. Bcard[1] = '\0';
  32.  
  33. or 
  34.  
  35. in stead of strncpy use strcpy as follows:
  36. strcpy(Bcard, "B");
  37.  
  38. >   strncat(Bcard,&line[1],1);
  39. >   strncat(Bcard, Space,3);
  40.  
  41. >   padright(Bcard,5,7,3,3);
  42. >   padright(Bcard,8,12,5,5);
  43. >   padright(Bcard,13,18,6,6);
  44. >   strncat(Bcard," ",1);
  45.  
  46. >   padright(Bcard,20,22,3,3);
  47. >   padright(Bcard,23,27,5,5);
  48. >   padright(Bcard,28,33,6,6);
  49. >   strncat(Bcard," ",1);
  50.  
  51. >   padright(Bcard,35,37,3,3);
  52. >   padright(Bcard,38,43,5,5);
  53. >   padright(Bcard,43,48,6,6);
  54. >   strncat(Bcard," ",1);
  55.  
  56. >   padright(Bcard,50,52,3,3);
  57. >   padright(Bcard,53,57,5,5);
  58. >   padright(Bcard,58,63,6,6);
  59. >   strncat(Bcard," ",1);
  60.  
  61. >   padright(Bcard,65,67,3,3);
  62. >   padright(Bcard,68,72,5,5);
  63. >   padright(Bcard,73,78,6,6);
  64. >   strncat(Bcard,"\n",1);
  65. >   
  66. >   fputs(Bcard,fpcardwrt);
  67. >  
  68. >  }
  69.  
  70. Hope to have helped you,
  71.  
  72. Christ Vandromme.
  73.  
  74.  
  75. ----------------------------------------------
  76. Email me at Christ.Vandromme@ping.be
  77.  
  78. Home page: http://www.ping.be/user/Christ.Vandromme
  79.  
  80.